const BASE_URL = "https://api-hmugo-web.itheima.net/api/public/v1";
let ajaxTimes = 0;
export  const myRequest =(options)=>{
	ajaxTimes++;
	uni.showLoading({
		title:"加载中..."
	})
	return new Promise((resolve,reject)=>{
		uni.request({
			url:BASE_URL + options.url,
			method: options.method || "GET",
			data:options.data,
			success: (res) => {
				if(res.data.status && res.data.status !== 0){
					uni.showToast({
						title:"获取数据失败!"
					})
				}
				resolve(res)
			},
			fail(err) {
				uni.showToast({
					title:"请求接口失败!"
				})
				reject(err)
			},
			complete() {
				ajaxTimes--;
				if(ajaxTimes==0){
					uni.hideLoading()
				}
			}
		})
	})	
}
